import router from "./index";
import { useDarkModeStoreHook } from "@/store/modules/dark-mode";

router.beforeEach((to, from, next) => {
  const darkModeStore = useDarkModeStoreHook();
  if (
    typeof to.name === "string" &&
    [
      "Home",
      "TemplateList",
      "TempleVideo",
      "CreatePictureVideo",
      "AiCopyGenerator",
      "AiCopyGenHistory"
    ].includes(to.name)
  ) {
    if (!darkModeStore.darkMode) {
      darkModeStore.toggleDarkMode(); // 切换为暗黑模式
    }
  } else {
    if (darkModeStore.darkMode) {
      darkModeStore.toggleDarkMode(); // 切换为浅色模式
    }
  }
  next();
});
